<?php
/**
 * Akimimi front
 * BuyerPointListView
 * by M.Wang
 */
require_once '../app/views/BaseView.php';
require_once "../". $GLOBALS["local"] ."/"."error.php";
class BuyerPointListView extends BaseView {

    public $logs;
    public $user;
    public $nowpage;
    public function getPage(){
        $arr_navsetting = array(
            array('url'=>'/userinfo/index', 'text'=>MYAKIMIMITXT),
            array('text'=>PLLPAGETITLE)
        );
        $this->setPageTitle(PLLPAGETITLE);
        $this->addCSS('myaccount.css');
        $this->addCSS('myaccountleftnav.css');
        $header = '';
        require_once '../app/views/MyAccoutLeftNavView.php';
        $myAccountLeftNavView = new MyAccountLeftNav();
        $str_result = $header
                    . $this->getNavigation($arr_navsetting)
                    . "<div id='mymimi_body'>"
                    . $myAccountLeftNavView->getMyAccountLeftNav()
                    . $this->getContent($str_message)
                    . '</div>';
        return $this->getHtmlPage($str_result);
    }

    public function getContent(){
        $arr_constants = get_defined_constants();
        $str_result =
<<<str_result
    <div id='mymimi_right'>
        <div class='right_bj'></div>
        <div style='margin-top:20px;margin-left:20px;'>
            <div>
                <span>{$arr_constants['USERNAMETXT']}{$this->user['name']}</span>
                <span style='margin-left:50px;'>{$arr_constants['USERCOUNTPOINTTXT']}{$this->user['points_buyer']}</span>
            </div>
str_result;
        if(!empty($this->logs)){
            $str_result.= <<<str_result
            <table cellpadding=2 cellspacing=0 style='margin-top:20px;empty-cells:show;border-collapse:collapse;'>
                <thead>
                    <tr>
                        <th style='width:40px;border:1px solid #eee;'>{$arr_constants['PLLNUMTXT']}</th>
                        <th style='width:80px;border:1px solid #eee;'>{$arr_constants['PLLGETPOINTTXT']}</th>
                        <th style='width:150px;border:1px solid #eee;'>{$arr_constants['PLLPOINTDESCRIPTION']}</th>
                        <th style='width:150px;border:1px solid #eee;'>{$arr_constants['PLLLOGCREATEDTXT']}</th>
                        <th style='width:80px;border:1px solid #eee;'>{$arr_constants['PLLCOUNTPOINTTXT']}</th>
                    </tr>
                </thead>
                <tbody>
str_result;
            foreach ( $this->logs as $arr_log ){
                if( !is_array( $arr_log ) )
                    continue;
            $str_logType = UserConstants::getAddUserPointOption($arr_log['type']) . ( empty($arr_log['description'])?'':"[{$arr_log['description']}]");
            $str_result.= <<<str_result
                    <tr>
                        <td style='text-align:center;border:1px solid #eee;'>{$arr_log['id']}</td>
                        <td style='text-align:center;border:1px solid #eee;'>{$arr_log['point']}</td>
                        <td style='text-align:center;border:1px solid #eee;'>{$str_logType}</td>
                        <td style='text-align:center;border:1px solid #eee;'>{$arr_log['created']}</td>
                        <td style='text-align:center;border:1px solid #eee;'>{$arr_log['current_point']}</td>
                    </tr>
str_result;
            }
        }else{
            $str_result.= <<<str_result
            <div style='margin-top:50px;text-align:center;'>
                <h5 style='font-size:1.5em;'>{$arr_constants['PLLLOGISEMPTYTXT']}</h5>
            </div>
str_result;
        }
        $pager = new Pager();
        $str_pager = $pager->paginate($this->nowpage, $this->logs['Count'], '/userinfo/mybuyerpointlist' );
        $str_result.= <<<str_result
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan='5' style='text-align:center;'><div class='p2_page'>{$str_pager}</div></td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
str_result;
        return $str_result;
    }

}
?>